using dkdm.danmuhelper;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace PickMeUp
{
    [RequireComponent(typeof(HierachyCommentComponent))]
    public abstract class BasePlot : MonoBehaviour, IInitializable, ILazyInitializable
    {
        public bool IsRunning { get; private set; }

        public abstract GameDefines.E_TaskPlot Plot { get; }

        public virtual void Initialized()
        {
            IsRunning = true;
            StartCoroutine(nameof(MianTaskPlotCortiune));
        }

        public virtual void LazyInitialized()
        {
            GamePlay.Instance.GameTaskPlotStateChangeSignal.Emit(Plot, true);
        }

        public virtual void PrepareFinalized()
        {
            GamePlay.Instance.GameTaskPlotStateChangeSignal.Emit(Plot, false);
        }

        public virtual void Finalized()
        {
            IsRunning = false;
            PrepareFinalized();
            StopAllCoroutines();
            GamePlay.Instance.EndTaskPlot();
        }

        protected abstract IEnumerator MianTaskPlotCortiune();
    }
}
